import {transfer} from '../../../api/virtualProduct'
const util = require('../../../utils/util.js')
let app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
	maxlength: 11,
  	account:"", //转赠的账号
	sheetsNumber:"", //转赠张数
	virtualStockId:"" //商品的id
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
		this.data.virtualStockId=options.virtualStockId
  },
  getInput(e) {
    this.data.account = e.detail.value
  },
  getsheetsNumber(e) {
    this.data.sheetsNumber = e.detail.value
  },
  cashOut () {
		if(util.isNull(this.data.account)){
			wx.showToast({ title: '请输入账号', icon: 'none', duration: 2000 })
			return
		}
		if(util.isNull(this.data.sheetsNumber)){
			wx.showToast({ title: '请输入转赠张数', icon: 'none', duration: 2000 })
			return
		}
		transfer({
			virtualStockId:this.data.virtualStockId,
			quantity:this.data.sheetsNumber,
			mobile:this.data.account,
		}).then(res=>{
			if(res.type='success'){
				wx.showToast({ title: '您已经赠送成功', icon: 'none'})
				wx.switchTab({
					url: '/pages/tabBar/water/water'
			 })
			}

		})
  },


})